import { Column, Entity, PrimaryGeneratedColumn, OneToOne, JoinColumn } from 'typeorm';
import { CommonEntity } from './../common.entity';
import { User } from '../framework/system/SysUser';
import { StudentTeamEntity } from '../studentTeam.entity';
import { GradeEntity } from '../grade.entity';
import { MajorEntity } from '../major.entity';

@Entity('student', {
	comment: '学生信息表',
	schema: 'public',
})
export class StudentEntity extends CommonEntity {
	@PrimaryGeneratedColumn({
		type: 'integer',
		name: 'student_id',
		comment: '学生ID',
	})
	studentId: number;

	@Column({
		type: 'integer',
		name: 'user_id',
		default: null,
		comment: '用户ID',
	})
	userId: number;


	@Column({
		type: 'character varying',
		name: 'stu_id',
		default: null,
		comment: '学号',
	})
	stuId: string;

	@Column({
		type: 'character varying',
		name: 'email',
		default: null,
		comment: '邮箱',
	})
	email: string;

	@Column({
		type: 'character varying',
		name: 'summary',
		default: null,
		comment: '个人简介',
	})
	summary: string;

	@Column({
		type: 'character varying',
		name: 'grade_id',
		default: null,
		comment: '年级ID',
	})
	gradeId: number;

	@Column({
		type: 'character varying',
		name: 'major_id',
		default: null,
		comment: '专业ID',
	})
	majorId: number;

	@Column({
		type: 'character varying',
		name: 'remark',
		default: null,
		comment: '备注',
	})
	remark: string;

	@Column({
		type: 'character',
		name: 'status',
		default: '0',
		comment: '状态（0正常 1停用）',
	})
	status: string;

	@Column({
		type: 'character',
		name: 'del_flag',
		default: '0',
		comment: '删除标志（0代表存在 2代表删除）',
	})
	delFlag: string;
	@OneToOne(() => User, (user) => user.student)
	@JoinColumn({ name: 'user_id', referencedColumnName: 'userId' })
	user: User;
	@OneToOne(() => StudentTeamEntity, (studentTeam) => studentTeam.student)
	studentTeam: StudentTeamEntity;
	@OneToOne(()=>GradeEntity,(grade)=>grade.students)
	@JoinColumn({ name: 'grade_id', referencedColumnName: 'gradeId' })
	grade:GradeEntity
	@OneToOne(()=>MajorEntity,(major)=>major.students)
	@JoinColumn({ name: 'major_id', referencedColumnName: 'majorId' })
	major:MajorEntity
}
